package com.dfiov.cloud.msmtools.mapper.msoptaccountMapper;

import com.dfiov.cloud.msmtools.mapper.entity.msmtools.OptUserDo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface OpUserMapper {

    @Select("<script> " +
            "SELECT * FROM opt_user u " +
            "WHERE u.del_flag = 0 " +
            "<if test='realName!=null'> AND u.real_name like #{realName} </if> " +
            "<if test='username!=null'> AND u.username like #{username} </if> " +
            "<if test='phone!=null'> AND u.phone = #{phone} </if> " +
            "<if test='orgCode!=null'> AND u.org_code = #{orgCode} </if> " +
            "limit 1 " +
            "</script>")
    OptUserDo getOpUser(@Param("realName")String realName,
                        @Param("phone")String phone,
                        @Param("username")String username,
                        @Param("orgCode")String orgCode);


    @Update("UPDATE opt_user SET locked = 0 WHERE username = #{username}")
    long updateOpUserLockStatus(@Param("username")String username);
}
